#include "GeometricRestartsManager.cuh"

__device__ GeometricRestartsManager::GeometricRestartsManager(
		int initial_conflicts_until_restart, float increase_factor)
{
	conflicts_until_restart = initial_conflicts_until_restart;
	this->increase_factor = increase_factor;
	current_conflicts_number = 0;
}

__device__ void GeometricRestartsManager::signal_conflict()
{
	current_conflicts_number++;
}

__device__ void GeometricRestartsManager::handle_restart()
{
	current_conflicts_number = 0;
	conflicts_until_restart = (int) (conflicts_until_restart*increase_factor);
}

__device__ bool GeometricRestartsManager::should_restart()
{
	if(current_conflicts_number >= conflicts_until_restart)
	{
		handle_restart();
		return true;
	}
	else
		return false;
}
